//
//  HWMyNoticeCell.m
//  嗨文
//
//  Created by 响当当 on 2019/1/16.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWMyNoticeCell.h"

@interface HWMyNoticeCell()
@property (nonatomic, strong)UIImageView *iconImageView;//icon
@property (nonatomic, strong)UILabel *titleLabel;//标题
@property (nonatomic, strong)UILabel *contextLabel;//内容
@property (nonatomic, strong)UILabel *timeLabel;//时间
@property (nonatomic, strong)UIView *lineView;//下划线
@end

@implementation HWMyNoticeCell

- (UIImageView *)iconImageView
{
    if (!_iconImageView)
    {
        _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,21*kUIScaleBasePlus,34*kUIScaleBasePlus,34*kUIScaleBasePlus)];
        _iconImageView.image = [UIImage imageNamed:@"systemnotice"];
    }
    return _iconImageView;
}

- (UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+15*kUIScaleBasePlus,12*kUIScaleBasePlus,0,15*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x212121)
                                             textFont:16*kUIScaleBasePlus];
    }
    return _titleLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,13*kUIScaleBasePlus,0,9*kUIScaleBasePlus)
                                           textAligment:NSTextAlignmentLeft
                                               textClor:LCHexColor(0x808080)
                                               textFont:12*kUIScaleBasePlus];
    }
    return _timeLabel;
}

- (UILabel *)contextLabel
{
    if (!_contextLabel)
    {
        _contextLabel = [HWUtilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+15*kUIScaleBasePlus,36*kUIScaleBasePlus,0,29*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x808080)
                                             textFont:13*kUIScaleBasePlus];
        _contextLabel.numberOfLines = 0;
    }
    return _contextLabel;
}

- (UIView *)lineView
{
    if (!_lineView)
    {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(63*kUIScaleBasePlus,69*kUIScaleBasePlus,312*kUIScaleBasePlus,1*kUIScaleBasePlus)];
        _lineView.backgroundColor = LCHexColor(0xE6E6E6);
    }
    return _lineView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.iconImageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.contextLabel];
        [self.contentView addSubview:self.timeLabel];
        [self.contentView addSubview:self.lineView];
    }
    return self;
}

- (void)getMyInformationdate:(NSDictionary *)dic
{
    
    self.titleLabel.text = IFNULL(dic[@"informName"], [NSString string]);
    [self.titleLabel sizeToFit];
    
    self.contextLabel.text = IFNULL(dic[@"informContent"], [NSString string]);
    [self.contextLabel sizeToFit];
    
    
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
//    [dateFormatter setDateFormat:@"HH:mm"];
//    NSString *nowDateTime = [dateFormatter stringFromDate:[NSDate date]];
    self.timeLabel.text = IFNULL(dic[@"informTime"], [NSString string]);
    [self.timeLabel sizeToFit];
    [self.timeLabel setX:SCREEN_WIDTH-self.timeLabel.frame.size.width-10*kUIScaleBasePlus];
}
@end
